<?PHP
include("../config/connect.php");
include("../public/common.php");

$id = CheckUrlParamNoDie("id");
$nPage = CheckUrlParamNoDie("page");

if($nPage == "")
	$nPage = 0;
	
if( $id == "" )
{
	echo "error";
	exit;
}

// Normal
$count = mysql_num_rows(mysql_query("select id from user where commend_id='".$id."'"));
$countHasBuy = 0;

$PAGE_SIZE = 6;
$limit = " limit ". $nPage*$PAGE_SIZE .",$PAGE_SIZE";
$sql = "select id,tb_id,reg_time,type from user where commend_id='".$id."' order by reg_time desc".$limit;
$result = mysql_query( $sql );

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
	font-size: 12px;
	color: #000;
	font-family: 宋体;
}
.ajaxtooltip{
position: absolute; /*leave this alone*/
display: none; /*leave this alone*/
width: 300px;
left: 0; /*leave this alone*/
top: 0; /*leave this alone*/
background: lightyellow;
border: 2px solid gray;
border-width: 1px 2px 2px 1px;
padding: 5px;
}
</style>
<script type="text/javascript" src="http://www.gouwutu.com/js/jquery-1.2.2.pack.js"></script>
<script type="text/javascript" src="http://www.gouwutu.com/js/ajaxtooltip.js"></script>
</head>

<body style="margin-left:0; margin-top:0; margin-right:0; margin-bottom:0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
      <tr bgcolor="#F4D662">
        <td width="151" height="24" align="center"><strong>序号</strong></td>
        <td width="397" align="center"><strong>用户账号</strong></td>
        <td width="100" align="center"><strong>用户类型</strong></td>
        <td width="281" align="center"><strong>注册日期</strong></td>
        <td width="396" align="center"><strong>状态</strong></td>
      </tr>
      <?PHP 
	  $i = $PAGE_SIZE * $nPage + 1;
	  if ( $count > 0 ) 
	  {
	  while( $result && $row = mysql_fetch_assoc( $result )) {
	  ?>
      <tr bgcolor="<?PHP if ($i % 2 == 0) echo "#EAE7BB"; else echo "#EEEEEE" ?>">
        <td height="24" align="center"><?PHP echo $i; ?></td>
        <td align="center"><?PHP $tmp=strlen($row["tb_id"]); echo substr($row["tb_id"], 0, min($tmp, 4)).substr("***************", 0, $tmp-min($tmp, 8)).substr($row["tb_id"], min($tmp, 4) + $tmp-min($tmp, 8), $tmp-min($tmp, 7)); ?></td>
        <td align="center"><?PHP if ($row["type"]=="N") echo "普通用户"; else echo "联盟用户"; ?></td>
        <td align="center"><?PHP echo $row["reg_time"]; ?></td>
        <td align="center" title="ajax:tooltip_userinfo.php?userid=<?PHP echo $row["id"]; ?>">
        <?PHP 
		if (mysql_num_rows(mysql_query("select id from order_handle_report where user_id='".$row["id"]."' limit 1")) > 0)
		{
			echo "<img src='images/hasbuy.gif' />&nbsp;已购物";
			$countHasBuy++;
		}
		else
			echo "<img src='images/nobuy.gif' />&nbsp;未购物";
		?>
        </td>
      </tr>
      <?PHP
	  $i++;
		}
	}	// if
	else
	{
		echo "<tr><td align='center'>暂时没有数据</td></tr>";
	}
		?>
</table>

<div>
<table width="100%" cellspacing="4">
  <tr>
<td>
</td>

<td align="right">
<?PHP if ($count > $PAGE_SIZE) {?>
<a href="?page=0<?PHP echo "&id=$id"; ?>">首页</a>&nbsp;&nbsp;
<?PHP if ($nPage > 0) {?>
<a href="?page=<?PHP echo $nPage-1; ?><?PHP echo "&id=$id"; ?>">上一页</a>&nbsp;&nbsp;
<?PHP } ?>
<?PHP if ($nPage < intval($count / $PAGE_SIZE)) {?>
<a href="?page=<?PHP echo $nPage+1; ?><?PHP echo "&id=$id"; ?>">下一页</a>&nbsp;&nbsp;
<?PHP } ?>
<a href="?page=<?PHP echo intval($count / $PAGE_SIZE); ?><?PHP echo "&id=$id"; ?>">尾页</a>&nbsp;&nbsp;
<?PHP } ?>
</td>

</tr></table>
</div>

</body>
</html>
